﻿using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Runtime.Serialization;
using System.Collections;
using System.Data;
using System.ComponentModel;
using System.Data.OracleClient;
using WPFExcelReport.Helpers;
using WPFExcelReport.Controls;
namespace WPFExcelReport
{
    public partial class VICC_JJRULES
    {

        public void SetUpNewRow(ref DataRow dwReturn)
        {

            switch (app.company)
            {
                case "YGR":
                case "YCC":
                default:
                    dwReturn["ROWNID"] = "";
                    dwReturn["RTYPE"] = "1";
                    dwReturn["MACHINEID"] = "M_DX";
                    dwReturn["PROPERTY"] = "JP01";
                    dwReturn["RGROUP"] = "10";
                    dwReturn["RULEID"] = "1";
                    dwReturn["JOBVDES"] = "ºóÕûÀí·½Ê½";
                    dwReturn["LOGIC"] = "=";
                    dwReturn["RULEDES"] = "";
                    dwReturn["POINTS"] = "0";
                    dwReturn["RATIO"] = "1";
                    dwReturn["DIFF"] = "0";
                    dwReturn["JJVALUE"] = "";
                    dwReturn["WD"] = "0";
                    dwReturn["WDDAYS"] = "0";
                    dwReturn["LOWPOINTS"] = "";
                    dwReturn["HIGHPOINTS"] = "";
                    dwReturn["REMARK"] = "0"; 
                    break;
            }
        }
        public void InsertICC_JJRULES(DataRow dwData, string ITXDBVERSION = "50.24")
        {

            or1 = OracleDB.CreateCommand();
            switch (ITXDBVERSION)
            {
                default:
                case "YGR":
                    or1.CommandText = "INSERT INTO ICC_JJRULES ( ROWNID,RTYPE,MACHINEID,PROPERTY,RGROUP,RULEID,JOBVDES,LOGIC,RULEDES,MINUTES,RATIOM,POINTS,RATIOP,DIFF,JJVALUE,WD,WDDAYS,LOWPOINTS,HIGHPOINTS,MAXLIMIT,REMARK)"
                + " VALUES (:ROWNID:,:RTYPE:,:MACHINEID:,:PROPERTY:,:RGROUP:,:RULEID:,:JOBVDES:,:LOGIC:,:RULEDES:,:MINUTES:,:RATIOM:,:POINTS:,:RATIOP:,:DIFF:,:JJVALUE:,:WD:,:WDDAYS:,:LOWPOINTS:,:HIGHPOINTS:,:MAXLIMIT:,:REMARK:)";

                    or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
                    break;
            }
            Connect2Proxy(or1);
        }
        public DataSet QJJRULES01(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "SELECT * FROM ICC_JJRULES WHERE  ROWNID=:ROWNID: ";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            SResult = Connect2Proxy(or1);
            SResult.Tables[0].TableName = TableName;
            return SResult;
        }
        public DataSet QJJRULES00(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "SELECT * FROM ICC_JJRULES "
                + " ORDER BY RGROUP,RULEID"; 
            SResult = Connect2Proxy(or1);
            SResult.Tables[0].TableName = TableName;
            return SResult;
        }
        public void DJJRULES01(DataRow dwData)
        {

            or1 = OracleDB.CreateCommand();
            or1.CommandText = "DELETE  FROM ICC_JJRULES WHERE  ROWNID=:ROWNID: ";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData); 
            Connect2Proxy(or1);
        }
        public void DJJRULES00(DataRow dwData)
        {

            or1 = OracleDB.CreateCommand();
            or1.CommandText = "DELETE FROM ICC_JJRULES";
            Connect2Proxy(or1);
        }

        public void UpdateICC_JJRULES(DataRow dwData, string ITXDBVERSION = "50.24", int option = 1)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "UPDATE ICC_JJRULES SET ROWNID=:ROWNID:,RTYPE=:RTYPE:,MACHINEID=:MACHINEID:,PROPERTY=:PROPERTY:,RGROUP=:RGROUP:,RULEID=:RULEID:,JOBVDES=:JOBVDES:,LOGIC=:LOGIC:,RULEDES=:RULEDES:,MINUTES=:MINUTES:,RATIOM=:RATIOM:,POINTS=:POINTS:,RATIOP=:RATIOP:,DIFF=:DIFF:,JJVALUE=:JJVALUE:,WD=:WD:,WDDAYS=:WDDAYS:,LOWPOINTS=:LOWPOINTS:,HIGHPOINTS=:HIGHPOINTS:,MAXLIMIT=:MAXLIMIT:,REMARK=:REMARK:"
           + "     WHERE ROWNID =:ROWNID: ";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            Connect2Proxy(or1);
        }
    }
}
